package top.shen33.yang.services.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import top.shen33.yang.model.entity.SysRole;
import top.shen33.yang.mapper.SysRoleMapper;
import top.shen33.yang.services.SysRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 系统角色表 服务实现类
 * </p>
 *
 * @author oreilly
 * @since 2018-08-23
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole>implements SysRoleService {


    @Override
    public Class clazz() {
        return SysRole.class;
    }

    @Override
    @Transactional
    public void doAdd(SysRole itemSysRole) {

        itemSysRole.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doUpdate(SysRole itemSysRole) {

        itemSysRole.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doDelete(String[] ids) {

        QueryWrapper<SysRole> ew = new QueryWrapper<>();
        ew.in("sid", ids);
        new SysRole().delete(ew);
    }


    @Override
    public List<SysRole> all(SysRole itemSysRole) {

        return this.baseMapper.all(itemSysRole);
    }

    @Override
    @Transactional
    public void doImport(List<SysRole> dataList) {

    }


    @Override
    public Page<SysRole> pageInfo(Page page, SysRole itemSysRole) {

        List<SysRole> dataList = this.baseMapper.pageInfo(page, itemSysRole);
        page.setRecords(dataList);
        return page;
    }

    @Override
    public SysRole getOne(String id) {
        return getById(id);
    }
}
